﻿using ElectronicSelling.BaseEntity;
using ElectronicSelling.DataAccess;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace ElectronicSelling.BusinessLogic
{
    public class OrderLogic
    {
        public static bool IsInsertOrder(Order order)
        {
            return OrderAccess.IsInsertOrder(order);
        }

        public static int GetMaxOrderId()
        {
            return OrderAccess.GetMaxOrderId();
        }

        public static bool IsInsertOrderDetail(OrderDetail orderDetail)
        {
            return OrderAccess.IsInsertOrderDetail(orderDetail);
        }

        /// <summary>
        /// lấy theo ngày
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static DataTable GetOrderInDay(Order order)
        {
            return OrderAccess.GetOrderInDay(order);
        }

        /// <summary>
        /// lấy tất
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static DataTable GetOrderListByCusId(Order order)
        {
            return OrderAccess.GetOrderListByCusId(order);
        }

        public static bool IsUpdatedPassWord(User user)
        {
            return OrderAccess.IsUpdatedPassWord(user);
        }

        /// <summary>
        /// customer delete order 
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static bool IsDeletedOrderByCus(Order order)
        {
            return OrderAccess.IsDeletedOrderByCus(order);
        }

        public static DataTable GetOrderStatus(Order order)
        {
            return OrderAccess.GetOrderStatus(order);
        }

        /// <summary>
        /// check order processed
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static bool IsOrderProcessed(Order order)
        {
            DataTable dt = GetOrderStatus(order);
            DataRow dr = dt.Rows[0];
            return Convert.ToBoolean(dr["ApproveStatus"].ToString());
        }

        public static DataTable GetOrderDetail(OrderDetail orderDetail)
        {
            return OrderAccess.GetOrderDetail(orderDetail);
        }
    }
}